<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
	<head>
		<title>编辑奖品</title>
		<meta name="decorator" content="default"/>
		<script type="text/javascript">
			$(function() {
				//初始化表单验证
				$("#inputForm").initValidform();			
								
				//下拉框选择
				changeOption();
												
			});
			
			function changeOption(){
				var type = $("#selectOption").find("option:selected").text();
				
				if(type == '优惠券' || type == '提货券'){
					$("#couponForm").attr('datatype','*');
				}else{
					$("#couponForm").removeAttr('datatype');
				}
				
				if(type != '积分'){
					var point = $("#priceInput").val();
					if(point != '0'){
						$("#priceInput").val('0');
					}
				}
							
			}
			
			function change(){				
				changeOption();				
			}
			
		</script>
	</head>
	
	<body class="mainbody">
		<form:form id="inputForm" modelAttribute="award" action="${ctx}/sd/award/save" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<!--导航栏-->
			<div class="location">
				<a href="${ctx}/sd/award/list" class="back"><i></i><span>返回列表页</span></a>
				<a href="${ctx}/center" class="home"><i></i><span>首页</span></a> 
				<i class="arrow"></i> 
				<a href="${ctx}/sd/award/form?id=${award.id}"><span>奖品</span></a>
				<shiro:hasPermission name="sd:award:edit"><i class="arrow"></i><span>${not empty award.id ? '修改':'添加' }奖品</span></shiro:hasPermission>
			</div>	
			<div class="line10"></div>
			<!--/导航栏-->
	
			<!--内容-->
			<div id="floatHead" class="content-tab-wrap">
				<div class="content-tab">
					<div class="content-tab-ul-wrap">
						<ul>
							<li><a class="selected" href="javascript:;">奖品信息</a></li>
						</ul>
					</div>
				</div>
			</div>
			<div class="tab-content">
				<dl>
					<dt>名称</dt>
					<dd>
						<form:input path= "name"  htmlEscape="false" maxlength="255" class="required" cssClass="input normal" nullmsg="请输入名称" errormsg="请输入名称" sucmsg=" "/>
						<span class="Validform_checktip">*请输入名称</span>
					</dd>
				</dl>
				<dl>		
					<dt>是否分享</dt>	
					<dd>
							<div class="rule-multi-radio">
							    <form:radiobutton path="isShare"  value="0"  label="否" checked="checked" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请选择是否分享" errormsg="请选择是否分享" sucmsg=" "/>
							    <form:radiobutton path="isShare"  value="1"  label="是" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请选择是否分享" errormsg="请选择是否分享" sucmsg=" "/>
							</div>
					</dd>
				</dl>				
				<dl>
					<dt>礼品类型</dt>
					<dd>
						<div class="rule-single-select single-select" >
							<form:select id="selectOption" onchange="change()" path="awardTypeId" errormsg="请输入选择节点" sucmsg=" ">
							<c:choose>
							   <c:when test="${awardtypeList==null}">  
								   <form:option value="0"  label="暂无类型"></form:option>
							   </c:when>
							   <c:otherwise> 
						    	  <form:options items="${awardtypeList}" itemLabel="name" itemValue="id"/>
							   </c:otherwise>
							</c:choose>	
							</form:select>
						</div>
						<span class="Validform_checktip"></span>				
					</dd>					
				</dl>				
				<dl>				
					<dt>积分</dt>
					<dd>
						<form:input id="priceInput"   path="price" htmlEscape="false" maxlength="50"  datatype="*"  class="required" cssClass="input normal"  nullmsg="请输入积分" errormsg="请输入积分" sucmsg=" "/>
						<span class="Validform_checktip">*请输入积分（积分类型必填）</span>
					</dd>
				</dl>
				<dl>
					<dt>数量</dt>
					<dd>
						<form:input path="amount" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请输入数量" errormsg="请输入数量" sucmsg=" "/>
						<span class="Validform_checktip">*请输入数量</span>
					</dd>
				</dl>
				<dl>
					<dt>优惠券编号</dt>
					<dd>
						<form:input id="couponForm" path="couponId" htmlEscape="false" maxlength="50" class="required"  cssClass="input normal"   nullmsg="请输入优惠券编号" errormsg="请输入优惠券编号" sucmsg=" "/>
						<span class="Validform_checktip">*请优惠券编号（优惠券类型必填）</span>
					</dd>
				</dl>								
				<dl>
					<dt>图片</dt>
					<dd>
						<form:input path="image" htmlEscape="false" maxlength="255" class="required" cssClass="input normal" datatype="*" nullmsg="请输入图片" errormsg="请输入图片" sucmsg=" "/>
						<span class="Validform_checktip">*请输入图片</span>
					</dd>
				</dl>
				<dl>
					<dt>描述</dt>
					<dd>
						<form:input path="description" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请输入描述" errormsg="请输入描述" sucmsg=" "/>
						<span class="Validform_checktip">*请输入描述</span>
					</dd>
				</dl>
			</div>
			<!--/内容-->
	
			<!--工具栏-->
			<div class="page-footer">
				<div class="btn-wrap">
					<input type="submit" name="btnSubmit" value="提交保存" id="btnSubmit" class="btn" />
					<input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
				</div>
			</div>
			<!--/工具栏-->
		</form:form>
	</body>
</html>

